//
//  Emoticon.swift
//  表情键盘
//
//  Created by 陈恒均 on 2018/2/23.
//  Copyright © 2018年 陈恒均. All rights reserved.
//

import UIKit

class Emoticon: NSObject {
    var code : String?
    var png : String?
    var chs : String?
    
    // MARK:- 数据处理
    var emojiCode : String?
    var pngPath : String?
    var isRemove : Bool = false
    var isEmpty = false
    
    
    
    init(dict : [String : String]) {
        super.init()
        code = dict["code"]
        png = dict["png"]
        chs = dict["chs"]

        //对数据进行处理
        if let code = code {
            let scanner = Scanner(string: code)
            
            var value : UInt32 = 0
            
            scanner.scanHexInt32(&value)
            
            let c = Character(UnicodeScalar(value)!)
            
            emojiCode = String(c)
        }
      
        //对pngPath进行处理
        guard let png = png else {
            return
        }
        pngPath = Bundle.main.bundlePath + "/Emoticons.bundle/" + png
      
        
        
        
    }
    
    init(isRomove : Bool) {
        self.isRemove = true
    }
    init(isEmpty : Bool) {
        self.isEmpty = true
    }
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
//    override var description: String{
//        return dictionaryWithValues(forKeys: ["emojiCode","pngPath","chs"]).description
//    }
}
